new Vue({
	el: '#app',
	data: {
		sdate: '',
		edate: '',
		sname: '',
		sprojcet: '',
		list: [],
		info: {},
		headers:[
				{title:'体检患者',key:'realName'},
				{title:'身份证号',key:'cardId'},
				{title:'套餐名字',key:'orderName'},
				{title:'体检时间',key:'createTime'},
				{title:'订单状态',key:'status'},
				],
		open: false,
		totalNum:'',
		openNum:1,
	},
	created() {

		showHead();
		showLeftMenu();
		// 在页面创建时发送Ajax请求
		var params = new URLSearchParams(window.location.search);
		
		this.scardid = params.get('card_id'); 
		
		this.getOrderList(0)
		
		
	},
	methods: {
		getOrderList(page){
			
			var _this = this;
			if(this.sdate != '' && this.edate !=''){
				this.sdate = (new Date(sdate)).getTime()/1000;
				this.edate = (new Date(edate)).getTime()/1000;
				if(this.sdate == this.edate){
					alert("起始和结束时间不能为同一天");
					return;
				}else if(this.edate < this.sdate){
					alert("结束时间不能小于起始时间");
					return;
				}
			}
			
			
				$.ajax("/doctor/Order/getOrderList", {
					type: "POST",
					data: {
						sdate:_this.sdate,
						edate:_this.edate,
						sname:_this.sname,
						sprojcet:_this.sprojcet,
						page:page,
					},
					success: function(data, textStatus) {
						let datas = JSON.parse(data);
						if (datas.statusCode == 200) {
							_this.list = datas.datas.order;
							_this.totalNum = datas.datas.count;
						} else {
							reject(datas.errMsg);
						}
					}
				})
		},
		getOrderInfo(id){
			
				var _this = this;
				$.ajax("/doctor/Order/getOrderInfo", {
					type: "POST",
					data: {
						id:id,
					},
					success: function(data, textStatus) {
						let datas = JSON.parse(data);
						if (datas.statusCode == 200) {
							let info = datas.datas.order;
							_this.info = info;
						} else {
							datas.errMsg;
						}
					}
				})
		},
		showFrom: function(id) {
			this.getOrderInfo(id)
			this.open = true;
		},
		closeFrom: function() {
			this.open = false;
		},
		updateList(openNum){	
			this.openNum = openNum
			this.getOrderList(openNum)	
			console.log(openNum)
		},
		updateOpen(open){
				this.open = open
		}
		
	},
	computed: {

	},

})